<?php
declare(strict_types=1);

namespace App\Resource\Group\Bulletin;


use Illuminate\Http\Resources\Json\JsonResource;

class Resource extends JsonResource
{
    public function toArray($request)
    {
        if(empty($this->id)){
            return [];
        }
        return [
            'id' => $this->id,
            'group_id' => $this->group_id,
            'user_id' => $this->user_id,
            'nickname' => empty($this->member->nickname) ? $this->user->nickname : $this->member->nickname,
            'avatar' => $this->user->head_picture ?? '',
            'content' => $this->content,
            'image' => $this->image,
            'created_at' => $this->created_at->timestamp,
        ];
    }
}